package interp;

import java.util.Arrays;

public class ArrayWrapper {
	private Object arr[];
	private int size=0;
	private String type;
	
	public ArrayWrapper(String type){
		if(type.equals("int") || type.equals("string") || type.equals("boolean")){
			this.type=type;
		}
		else{
			//TODO:RUNETIME ERROR
		}
	}
	
	public ArrayWrapper(String type, int size){
		this(type);
		initalizeArray(size);
	}
	
	private void initalizeArray(int size) {
		this.size=size;
		arr=new Object[size];
		for(int i=0;i<size;i++){
			if(type.equals("int")){
				arr[i]=new Integer(0);
			} else if (type.equals("boolean")){
				arr[i]=new Boolean(false);
			} else if (type.equals("string")){
				
			} else {
				//TODO: RUNTIME ERROR;
			}
		}
		
	}

	public void initalizeSize(int size){
		initalizeArray(size);
	}
	
	public Object getValue(int index){
		return arr[index];
	}
	
	public void setValue(Object elem,int index){
		arr[index]=elem;
	
	}
	
	public int getSize(){
		return size;
	}
	
	@Override
	public String toString(){
		String rv="";
		for(int i=0;i<size;i++){
			if(i != 0){
				rv=rv+"\n";
			}
			rv=rv+arr[i].toString();
		}
		return rv;
	}
	//TODO: initialize array values 

}
